{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "wd6157NQTqfU",
   "metadata": {
    "id": "wd6157NQTqfU"
   },
   "source": [
    "# 🔍 NLP + ASR Agent (Official BERT Large + Whisper Large V3)\n",
    "This notebook runs an agent with:\n",
    "- 🤖 **BERT Large Cased** for text classification or embedding\n",
    "- 🎙️ **Whisper Large V3** for audio transcription\n",
    "\n",
    "✅ Compatible with Google Colab Free (if Whisper uses fp16 and BERT is used efficiently)\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "TD8pkIV8er1I",
   "metadata": {
    "id": "TD8pkIV8er1I"
   },
   "source": [
    "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/bert_whisper_agent.ipynb)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "xQ1v5o47ejyu",
   "metadata": {
    "id": "xQ1v5o47ejyu"
   },
   "source": [
    "# Install required libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8yb2sVk7TqfX",
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "8yb2sVk7TqfX",
    "outputId": "13896ab6-f048-4850-d601-68435d0e0e8f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m30.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m18.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m23.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m10.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m26.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25h"
     ]
    }
   ],
   "source": [
    "\n",
    "!pip install -q transformers torchaudio accelerate torch"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "-YcKPAAhelsQ",
   "metadata": {
    "id": "-YcKPAAhelsQ"
   },
   "source": [
    "# Load BERT Large for text analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "Ppdx98tJTqfY",
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 177,
     "referenced_widgets": [
      "ef64ca729ce24516b53f811439c922de",
      "d86e086af653488bb3bb4daa1bc420fa",
      "18c04cece0c54cbb87cbb2391cc7150c",
      "62ad256a8769475daf4e8aacbdb10379",
      "0b1a3559484845c68d11951e9016a359",
      "293bdc33534349088e329d186645f643",
      "5da3f8d139a141a7b5ae2b87b8ab3a46",
      "083de2b5fc4843f99e778e8aa453c1b8",
      "41d9cffa0ec94a0f99c6a3e27dc97017",
      "bbc1dcfe4d0c4cef8574d6a09db2a32a",
      "ca9a87cbd99d491194edc4572ef7dc80",
      "7ea44cea34114e6784ebc339d78a8cb0",
      "0e0b43792f6e40aba2db124c465eb112",
      "2c36bed80a05477b85c7fdd07824a0d5",
      "0489bdfa20794a36a2757e75930fdeca",
      "9833eb7529f1470a95c67134c198ed70",
      "5986111ae7a34d9aa66278a6c9925960",
      "408c73a369194ca2b6585dba212727c2",
      "aec9f86597c842e388bfc7e495b702ab",
      "2b5a6970568d46f5a12d6f1c7bb9e4ee",
      "41597e7ccca34bc5ae22562260e764d1",
      "8b3f68f1e84e4af9a29c57447ff94027",
      "71296dd2da5e4c3d92d28204718d1d13",
      "ba135575d04048bea21a7ae63085e89f",
      "56bf69ca381f4c1895a15b61db7957e0",
      "16178169fc7a4b4b8ba39038b332bfb2",
      "692da53093d74e9bbba1c650ac7e6039",
      "4419b35b980c401997962e7c2bfe4672",
      "52c86dc445a24c5c9e2b8a02f12b9fb3",
      "858e97e2461d4b69bce55afac2a91c9b",
      "9a616db2cadb4618aa6492f1a1bef867",
      "2631be99ee604ca6859060402811e990",
      "b015448b956347b3867f19a8d5189517",
      "5a1baf78fe7e43f1bef9349959c643b2",
      "8aa423668aa545bbb6c3f332668b9bf5",
      "818e6bb7bb8b4f36ab47b511d8eea4f2",
      "879036aa5880478c80175ae0862cafc0",
      "1e61b33581e9499e81bc710e4d09d856",
      "ca424a49bdaa4653921f04f66295df8e",
      "3841511d0a714a328b58deeb4f185b3b",
      "ea6303e7aa264f739950572ec3eae4aa",
      "761736c6489e458fad5d258ed8e6485e",
      "15e90216f6c24b578106a08846739fcb",
      "f787c65d91b8477f8a6a199c57075dc8",
      "1ed0be1c90814e2c9f44b30f81db86b8",
      "80a88d56d5094e9ab4a21c68f02548e9",
      "1e0a05a8ca454a49addd483ee686d868",
      "9c933fdac2df4769bba416b241ce78ed",
      "a034c602568e4174a003045319c4f7ee",
      "db3c2fc0735d463694876e49ccbbd9d3",
      "1eaed0a8fdd94fd696431895e257c725",
      "94b7fba203734eca84683d121cac4197",
      "a0eb239bc63d44fd9866bd7b459a4bad",
      "c48ddcd435f547818779302134f21e66",
      "0c8d80a1ed8c4ad2b8921865064a9d3a"
     ]
    },
    "id": "Ppdx98tJTqfY",
    "outputId": "cb35f398-ef79-4864-f5e9-4556fd05a936"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ef64ca729ce24516b53f811439c922de",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/762 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7ea44cea34114e6784ebc339d78a8cb0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/1.34G [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "71296dd2da5e4c3d92d28204718d1d13",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/49.0 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5a1baf78fe7e43f1bef9349959c643b2",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "vocab.txt:   0%|          | 0.00/213k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1ed0be1c90814e2c9f44b30f81db86b8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/436k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "from transformers import AutoTokenizer, AutoModel\n",
    "import torch\n",
    "\n",
    "bert_model = AutoModel.from_pretrained(\"bert-large-cased\")\n",
    "bert_tokenizer = AutoTokenizer.from_pretrained(\"bert-large-cased\")\n",
    "\n",
    "def classify_text(text):\n",
    "    inputs = bert_tokenizer(text, return_tensors=\"pt\")\n",
    "    with torch.no_grad():\n",
    "        outputs = bert_model(**inputs)\n",
    "    return outputs.last_hidden_state.mean(dim=1)  # Sentence embedding"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bEjDTqPrens-",
   "metadata": {
    "id": "bEjDTqPrens-"
   },
   "source": [
    "# Load Whisper Large V3 for audio transcription"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "R0AGFFqTTqfY",
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 369,
     "referenced_widgets": [
      "012a21936d6c4884a7b84b2767584b58",
      "99d6c0fad4b748aa8738fa9a35f4e96f",
      "8ddf19cbbe724f58800c702b28e37801",
      "f2881943ec1b48e8b5ace9484815820c",
      "d6882c4c225a4b04af77d282bd7ce548",
      "8ae9c3217d4242bb913f6c2af6e0e19b",
      "0620a81309e249f490509ad62ce8afb6",
      "7debeb90d88546478719e8a625cb38fb",
      "07e65c48f16d4f9295ac639dd4b0b5c9",
      "036a8f64dc44488cabd463e1c15c4c91",
      "a9cb91371c374c288ee9b06d68327362",
      "350dbbd7e33d4a38865a41a85f0da780",
      "abbf7218263e44109604bac835e9e313",
      "294dd7f394114d8d893e9a5242099f71",
      "f4cc15dc389049c2b779439de6a59468",
      "c4480e04078a4c4cb65f7eeb87bd2183",
      "6a60214efc17431fac99e020321ddb64",
      "d24212a4256a436fbb5ae2eac6cb8c74",
      "bc6495fabaf6473a83c0c3a8a1b08422",
      "fdf9507288f34b578f59afb403e8a899",
      "c4c9f720c9eb4a71ad46bdf732273ed9",
      "567034a346624e1896bca65ea663ad08",
      "d5c0f34255d04845acee22ab2fd11275",
      "0d58eb843d174c15aee2f4877295d115",
      "0fd2307c7b894d68889f71345f48a2ad",
      "0ef40308eecb4817be0b56cdda125c38",
      "d673a07a18a54c5b915a8fa6580583bc",
      "2b73ef94e8f94aa1ab5e28cf3ae09a30",
      "75ad342121b3429aae7bbcf3aaf04fef",
      "dbb026b79b724d68a5eecbf6bf5fd957",
      "4d1c52a7062846ad8faf47d7aafb4127",
      "50c1e37bb01340ee8fbd09a4d9510fe9",
      "b29fb4842efc453b8f76e15859c091d9",
      "49cfe6d1837f4e16b8d7a9f7a622977b",
      "a75a0c15bc194163af7091e40ff31aa0",
      "598aebd58dae453d9be0bd515b2b6cd6",
      "98c7dbcdaf114ef0818c6a29200f414d",
      "6a0dc52da74949ffb8a5f4d8b81ba69e",
      "67adcfbdf31b4606b5b123402bbf1829",
      "db13444109ba4a4f828f402a1798f44f",
      "772e4b8bf52a4e098e76445a65487a4e",
      "79712d86e8fa432a8cdd055097429d81",
      "6b6a84ea89a64b208ef6989173e7b6c5",
      "fee4b1fe846c4c90b5a81f7344d9d2fa",
      "1859b8e9773d490880fb8f482bb2df7f",
      "3739191045f749209730cba003eb6ea0",
      "b9d5984462a243bbb490152374f00164",
      "d42b2cf9e5c849aa8297d85978340fa4",
      "4efc347cbbc54c1eb63edf2d1dd997c3",
      "be19baf94af44562b2392094688dff8c",
      "2d29827b9e154631bb2fdfbba8ad2e4f",
      "d82000f2e8524367b11b1736e4eed376",
      "a9e75f229ab04b1fb062d3dabe40d02e",
      "06445a9779894cef921650facc3cb915",
      "f9f294ebc94c40eab79b061bda373d60",
      "8549e6d45d904cb9860807c2114939f6",
      "329eb033407541e9a2c5854378d5bba9",
      "635ca5b07be2495eaafa5126637ee427",
      "43b284140ef14a0db4d9164d12333540",
      "902398ce9f8143478a3889c1af9693e9",
      "0bc9e112c9a2485fba38cad1e620d6d4",
      "dcdb799810e84d0b8de6a471b256fe46",
      "8b726a505b43413d853b1f5ba0404fd9",
      "b6b50da93bab490f8abf19930fa28f46",
      "2883a49d53fd4c0c9d4e97edf0005b9b",
      "0f88de1a2bce4af6be5c3cb88d0c0b17",
      "05d137a7667346abafdc2290320fedc2",
      "d1de71b61b6b442ab60e5c9d8d745cbe",
      "3662758074254935846f6eef56e6afd9",
      "43aa89322bc94fc3ab06ec84cf9b80b6",
      "9da6ad199a574479a75010da5b1a22dc",
      "6826f0af1489463f9e5bebcf422cf000",
      "486accbedd1648fe877cbafe9ceaf5a3",
      "ff7b49296a6440bf84f8734afc9a8a7b",
      "cb3b611a6ef04cd7a6a781dee1d0128d",
      "963c8f0e2cbb4a6a857a05e41b9cdc41",
      "4e551605bba34d12af90a9edb443e334",
      "87a22b9d9c9a4e0691a77fd34f15be4a",
      "327ba03562814fffaa695770e1f50235",
      "76551436a17f482fa16131b4985720a4",
      "86558c51b63b42fc9372779dd777379c",
      "b52881719c6a49a1a2dbbc906571d996",
      "71bd0c63a6564923b6c12cfd95bd0f99",
      "8126ef033a5d4beb9fe5ecb126d817b8",
      "557d5fa2a6404473960c9ad2d8ac9f61",
      "2d21c4ff75f549308297f7d38238ba60",
      "0a8b5af0b1e547ca9373b63f23724a52",
      "41448615087f4344a58a862d00ab7b60",
      "e801569aba0b4f51814d7498a362ae69",
      "259fd1045f3c451fb5b2bd8df2ff47fc",
      "cb885f28dcee412381d52e063a5d058b",
      "c5728b07bb224c4fb0ca656fa64b1137",
      "7b75953a78c847688eed9106a38bfec7",
      "e330f81594ea46cea5c4e94206144605",
      "bddcbf3209db4872aee6a7a6d8e57fdc",
      "32154e90fdbf4ca1a293a8c6c5d8ffd9",
      "ebc78e4a82d9430d8cc9047986e96185",
      "d0d664ee23ad47c6b6bb193eafcdfbf1",
      "1c39b174d83146e8a05b0af82c0191ef",
      "7972b5df2e4e465d868dbc827850e7a4",
      "e31441e745c04c308be3e81ebacf31c4",
      "f7a2d47725fc45d0b2f65b81b8cfa925",
      "f3f13df2d56a445ca472633188318b33",
      "37b8a1408f284eefb36be7c7babd3aa7",
      "0a2b79b882154b54bfd13090bf67af07",
      "eddcb5465f5648b69ac37c03887e494c",
      "49626d83e7c1403880ce17324fa7a514",
      "ddc300dd7e504840bc9dffd4666c0984",
      "b134fdc0b30445fa819a39bde44704d3",
      "61ce458fc45e4c709f6e4e2af9b4c881",
      "459a2c675632454c83a62b564853a6f3",
      "8b90fbbf1d234202b6aaec0a624874d9",
      "f104a1f9546e4f54ab86a44a4649ea33",
      "ae01037b6e084a15b0310cedfc0a6d53",
      "5050d0dbcfcc426f925fe39ecc975a72",
      "f2855e5586ce429da7472c9bcef8a88b",
      "05442b45864d417ab37710e2b3a9d05b",
      "68f72ed9e852416798a42c6a1147e540",
      "a6230b708cc24e9c85b9704ec0ece351",
      "62ff7ab4106648d4a2bc07b3048e1857",
      "3b1be73a026a4ea0b5686f10db107e3c"
     ]
    },
    "id": "R0AGFFqTTqfY",
    "outputId": "31805e6b-a58c-49cc-ae17-a2c20c5e0077"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "012a21936d6c4884a7b84b2767584b58",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "preprocessor_config.json:   0%|          | 0.00/340 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "350dbbd7e33d4a38865a41a85f0da780",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/283k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d5c0f34255d04845acee22ab2fd11275",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "vocab.json:   0%|          | 0.00/1.04M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "49cfe6d1837f4e16b8d7a9f7a622977b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/2.48M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1859b8e9773d490880fb8f482bb2df7f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "merges.txt:   0%|          | 0.00/494k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8549e6d45d904cb9860807c2114939f6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "normalizer.json:   0%|          | 0.00/52.7k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "05d137a7667346abafdc2290320fedc2",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "added_tokens.json:   0%|          | 0.00/34.6k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "87a22b9d9c9a4e0691a77fd34f15be4a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/2.07k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e801569aba0b4f51814d7498a362ae69",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/1.27k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7972b5df2e4e465d868dbc827850e7a4",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/3.09G [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "459a2c675632454c83a62b564853a6f3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "generation_config.json:   0%|          | 0.00/3.90k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "import torchaudio\n",
    "from transformers import WhisperProcessor, WhisperForConditionalGeneration\n",
    "\n",
    "processor = WhisperProcessor.from_pretrained(\"openai/whisper-large-v3\")\n",
    "model = WhisperForConditionalGeneration.from_pretrained(\"openai/whisper-large-v3\")\n",
    "model = model.to(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
    "\n",
    "def transcribe_audio(file_path):\n",
    "    audio, rate = torchaudio.load(file_path)\n",
    "    if rate != 16000:\n",
    "        resampler = torchaudio.transforms.Resample(orig_freq=rate, new_freq=16000)\n",
    "        audio = resampler(audio)\n",
    "    input_features = processor(audio.squeeze().numpy(), sampling_rate=16000, return_tensors=\"pt\").input_features\n",
    "    input_features = input_features.to(model.device)\n",
    "    predicted_ids = model.generate(input_features)\n",
    "    return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dSQGzAiGeqUS",
   "metadata": {
    "id": "dSQGzAiGeqUS"
   },
   "source": [
    "# Example BERT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7Q40yeA_TqfZ",
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "7Q40yeA_TqfZ",
    "outputId": "64785b48-77e1-4cd9-9d9b-6dec9e34b45c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BERT embedding shape: torch.Size([1, 1024])\n"
     ]
    }
   ],
   "source": [
    "# Example usage (requires uploaded audio file like sample.wav)\n",
    "# from google.colab import files\n",
    "# uploaded = files.upload()\n",
    "# print(transcribe_audio(\"sample.wav\"))\n",
    "\n",
    "embedding = classify_text(\"Google Colab is a great place to run small-scale NLP models.\")\n",
    "print(\"BERT embedding shape:\", embedding.shape)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
